<template>
	<!--我的-->
	<view class="content">
		<view class="userback">
			<img src="../../../static/icon/me.png">
			<view class="ad-me-text">
				<view class="userName">昵称：{{!customer.nickName ? '':customer.nickName}}</view>
				<view class="userName">电话：{{!customer.phone ? '':customer.phone}}</view>
			</view>
		</view>
		<!--列表开始-->
		<view class="mineList">
			<u-cell-group>
				<view class="myList">
					<u-cell icon="/static/icon/minehead.png" title="我的抬头" isLink url="./mine-wdtt/mine-wdtt-qy/ttlb">
					</u-cell>
				</view>
				<view class="myList">
					<u-cell icon="/static/icon/minepiao.png" title="我的票夹" isLink url="./ticket/index"></u-cell>
				</view>
				<view class="myList">
					<u-cell icon="/static/icon/minexx.png" title="完善信息" isLink url="./perferctUser/perfectUser">
					</u-cell>
				</view>
				<view class="myList">
					<u-cell icon="/static/icon/minescan.png" title="关于我们" isLink url="./contact/contact"></u-cell>
				</view>
				<view class="myList">
					<u-cell icon="/static/icon/store.png" title="我是商家" isLink url="../../business/mine/index"></u-cell>
				</view>
			</u-cell-group>
		</view>
		<!--列表结束-->
		<!--按钮开始-->
		<!-- <view class="home-button">
			<button @click="qhbutton" class="ad-botton">切换商家</button>
			<navigator url="../../business/mine/index"></navigator>
		</view>
 -->
	</view>
</template>
<script>
	export default {
		data() {
			return {
				customer: {
					nickName: '',
					phone: ''
				}, //个人信息


			}
		},
		onLoad() {
			var me = this
			var customers = uni.getStorageSync("user")
			console.log("user=" + JSON.stringify(customers))
			
				//根据用户id查询用户详情
				uni.request({
					url: me.$ServerUrl + '/invoice/api/customer/getCustomerById', //根据用户id查询用户详情
					data: {
						id: customers.id
					},
					header: {
						'content-type': 'application/x-www-form-urlencoded' // 默认值JSON格式
					},
					method: "GET",
					success: (res) => {
						console.log("用户详情：" + JSON.stringify(res))
						me.customer.nickName = res.data.nickName
						me.customer.phone = res.data.phone
					
						//如果没有完善客户信息
						if (!me.customer.nickName) {
							console.log("如果没有完善客户信息")
							uni.showModal({
								content: '请完善用户信息，在添加我的默认抬头吧',
								showCancel: false,
								success() {
									uni.redirectTo({
										url: './perferctUser/perfectUser'
									});
								}
							});
						}else{
						  this.$forceUpdate() //强制刷新页面
						}
					},
				})
				
			
		},
		methods: {
			qhbutton(e) {
				uni.navigateTo({
					url: "../../business/mine/index"
				})
			}
		}
	}
</script>
<style lang="less">
	page {
		width: 100%;
		height: 100%;
		background-color: #e1e5eb;
	}

	.userback {
		height: 150px;
		/* background-image: url('https://bpic.588ku.com//back_origin_min_pic/21/03/15/9e5c39dea7286bcb984e61e640f59baa.jpg!/fw/750/quality/99/unsharp/true/compress/true'); */
		background-repeat: no-repeat;
		background-size: 100%;
		text-align: left;
		background-color: #ffffff;
		display: flex;
		align-items: center;

	}

	.userback img {
		margin: 10px;
		border-radius: 51px;
		margin-top: 21px;
		width: 80px;
		height: 80px;
	}

	.userName {
		color: #111111;
		font-size: 0.9rem;
	}

	/* list */
	.myList {
		margin-bottom: 5px;
		background-color: #ffffff;
		border-radius: 5px;
	}

	.mineList {
		margin-top: -20px;
		margin-left: 10px;
		margin-right: 10px;
	}

	.home-button {
		margin: 10px;
	}

	.ad-botton {
		background-color: #505050;
		color: #FFFFFF;
	}
</style>
